package com.suao.web.controller.goods;

import com.suao.common.annotation.Log;
import com.suao.common.core.controller.BaseController;
import com.suao.common.core.domain.AjaxResult;
import com.suao.common.core.page.TableDataInfo;
import com.suao.common.enums.BusinessType;
import com.suao.common.utils.poi.ExcelUtil;
import com.suao.goods.domain.StorageSalesInfo;
import com.suao.goods.service.IStorageSalesInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 仓库销售流水Controller
 *
 * @author tyz
 * @date 2023-03-08
 */
@RestController
@RequestMapping("/goods/storageSalesInfo")
public class StorageSalesInfoController extends BaseController
{
    @Autowired
    private IStorageSalesInfoService storageSalesInfoService;

    /**
     * 查询仓库销售流水列表
     */
    @PreAuthorize("@ss.hasPermi('goods:storageSalesInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(StorageSalesInfo storageSalesInfo)
    {
        startPage();
        List<StorageSalesInfo> list = storageSalesInfoService.selectStorageSalesInfoList(storageSalesInfo);
        return getDataTable(list);
    }

    /**
     * 导出仓库销售流水列表
     */
    @PreAuthorize("@ss.hasPermi('goods:storageSalesInfo:export')")
    @Log(title = "仓库销售流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StorageSalesInfo storageSalesInfo)
    {
        List<StorageSalesInfo> list = storageSalesInfoService.selectStorageSalesInfoList(storageSalesInfo);
        ExcelUtil<StorageSalesInfo> util = new ExcelUtil<StorageSalesInfo>(StorageSalesInfo.class);
        util.exportExcel(response, list, "仓库销售流水数据");
    }

    /**
     * 获取仓库销售流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('goods:storageSalesInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(storageSalesInfoService.selectStorageSalesInfoById(id));
    }

    /**
     * 新增仓库销售流水
     */
    @PreAuthorize("@ss.hasPermi('goods:storageSalesInfo:add')")
    @Log(title = "仓库销售流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StorageSalesInfo storageSalesInfo)
    {
        return toAjax(storageSalesInfoService.insertStorageSalesInfo(storageSalesInfo));
    }

    /**
     * 修改仓库销售流水
     */
    @PreAuthorize("@ss.hasPermi('goods:storageSalesInfo:edit')")
    @Log(title = "仓库销售流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StorageSalesInfo storageSalesInfo)
    {
        return toAjax(storageSalesInfoService.updateStorageSalesInfo(storageSalesInfo));
    }

    /**
     * 删除仓库销售流水
     */
    @PreAuthorize("@ss.hasPermi('goods:storageSalesInfo:remove')")
    @Log(title = "仓库销售流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(storageSalesInfoService.deleteStorageSalesInfoByIds(ids));
    }
}
